/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.nxlv2.nomad.accessdb.services;

import com.nxlv2.nomad.accessdb.dao.ICommandeDao;
import com.nxlv2.nomad.accessdb.dao.IDetailCommandeDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcCommandeDao;
import com.nxlv2.nomad.accessdb.dao.jdbc.JdbcDetailCommandeDao;
import com.nxlv2.nomad.businessobjects.Article;
import com.nxlv2.nomad.businessobjects.Commande;
import com.nxlv2.nomad.businessobjects.DetailCommande;
import com.nxlv2.nomad.businessobjects.Prix;

/**
 *
 * @author Administrateur
 */
public class DetailCommandeServices {
    private static final IDetailCommandeDao dao = new JdbcDetailCommandeDao();
    private static final ICommandeDao daoC = new JdbcCommandeDao();
    
    /**
     * 
     * @param detailCommande
     * @param commande
     * @throws ServiceException 
     */
    public void create(DetailCommande detailCommande, Commande commande) throws ServiceException{
        dao.saveDetailCommande(detailCommande);
        daoC.lierDetailCommandeACommande(detailCommande, commande);
    }
    
    /**
     * 
     * @param detailCommande
     * @throws ServiceException 
     */
    public void update(DetailCommande detailCommande) throws ServiceException {
        dao.updateDetailCommande(detailCommande);
    }
    
    /**
     * 
     * @param detailCommande
     * @throws ServiceException 
     */
    public void delete(DetailCommande detailCommande) throws ServiceException {
        dao.deleteDetailCommande(detailCommande.getIdAppli());
    }
    
    /**
     * 
     * @param id
     * @return
     * @throws ServiceException 
     */
    public DetailCommande get(int id) throws ServiceException {
        return dao.findDetailCommandeById(id);
    }
    
    /**
     * 
     * @param detailCommande
     * @return Article
     * @throws ServiceException 
     */
    public Article getArticle(DetailCommande detailCommande) throws ServiceException {
        return dao.getArticle(detailCommande);
    }
    
    /**
     * 
     * @param article
     * @param detailCommande
     * @throws ServiceException 
     */
    public void linkArticle(Article article, DetailCommande detailCommande) throws ServiceException {
        dao.lierArticleADetailCommande(article, detailCommande);
    }
    
    /**
     * 
     * @param detailCommande
     * @return Prix
     * @throws ServiceException 
     */
    public Prix getPrix(DetailCommande detailCommande) throws ServiceException {
        return dao.getPrix(detailCommande);
    }
    
    /**
     * 
     * @param prix
     * @param detailCommande
     * @throws ServiceException 
     */
    public void linkPrix(Prix prix, DetailCommande detailCommande) throws ServiceException {
        dao.lierPrixADetailCommande(prix, detailCommande);
    }
}
